$(document).ready(function(){
    $.ajax({
        type:"post",url:"./ajax/center.php",success:function(data){
            data= $.parseJSON(data);
            //console.log(data);
            var a=new Array();
            for(var i=0;i<data.per.length;i++){
                a.push(data.per[i].category);
            }
            var b=new Array();
            for(var j=0;j<data.per.length;j++){
                b.push(data.per[j].score/data.tot);
            }
            var ctx = document.getElementById("myChart").getContext("2d");
            var data1 = {
                labels: a,
                datasets: [
//            {
//                label: "My First dataset",
//                backgroundColor: "rgba(179,181,198,0.2)",
//                borderColor: "rgba(179,181,198,1)",
//                pointBackgroundColor: "rgba(179,181,198,1)",
//                pointBorderColor: "#fff",
//                pointHoverBackgroundColor: "#fff",
//                pointHoverBorderColor: "rgba(179,181,198,1)",
//                data: [10, 10, 10, 20, 50, 50, 10]
//            },
                    {
                        label: "能力分配",
                        backgroundColor: "rgba(255,99,132,0.2)",
                        borderColor: "rgba(255,99,132,1)",
                        pointBackgroundColor: "rgba(255,99,132,1)",
                        pointBorderColor: "#fff",
                        pointHoverBackgroundColor: "#fff",
                        pointHoverBorderColor: "rgba(255,99,132,1)",
                        data: b
                    }
                ]
            };
            var myRadarChart = new Chart(ctx, {
                type: 'radar',
                data: data1,
                options: {
                    scale: {
                        reverse: false,
                        ticks: {
                            beginAtZero: true
                        }
                    }
                }
            });
            var calss=data.tot/data.max;
            if(calss<=0.2){
                $(".status_main li:nth-child(5)").css("color","red");
            }
            if(calss<=0.4&&calss>0.2){
                $(".status_main li:nth-child(4)").css("color","red");
            }
            if(calss<=0.6&&calss>0.4){
                $(".status_main li:nth-child(3)").css("color","red");
            }
            if(calss<=0.8&&calss>0.6){
                $(".status_main li:nth-child(2)").css("color","red");
            }
            if(calss<=1&&calss>0.8){
                $(".status_main li:nth-child(1)").css("color","red");
            }
    }
    });
});


